@extends('develop.layoutEdit')

@section('css')
    <style>
    .layer-go-back{
        display:none;
    }
    </style>
@endsection


@section('title')
    <li class="cur">
        <span>短信设置</span>
    </li>
@endsection

@section('content')

<div class="form-group">
    <label class="col-sm-3 control-label"><span class="red pr5">*</span>图片验证码：</label>
    <div class="col-sm-3">
        <div class="input-group">
            <input type="text" placeholder="图片验证码次数"  name="send_show_img_yzm" id="send_show_img_yzm"  class="form-control" value="{{$configure['send_show_img_yzm'] or 0}}">
            <span class="input-group-addon">次数</span>
        </div>
        <span class="help-block" style="clear: both;">发送短信第几次显示图片验证码</span>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label"><span class="red pr5">*</span>短信发送间隔时间：</label>
    <div class="col-sm-3">
        <div class="input-group">
            <input type="text" placeholder="短信发送间隔时间"  name="sms_send_time" id="sms_send_time"  class="form-control" value="{{$configure['sms_send_time'] or 60}}">
            <span class="input-group-addon">秒</span>
        </div>
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label"><span class="red pr5">*</span>每个手机号发送短信次数：</label>
    <div class="col-sm-3 form-inline">
        <input type="text" placeholder="每个手机号发送短信次数"  name="mobile_send_sms_num" id="mobile_send_sms_num"  class="form-control" value="{{$configure['mobile_send_sms_num'] or 10}}">&nbsp;&nbsp;
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label"><span class="red pr5">*</span>每个IP发送短信次数：</label>
    <div class="col-sm-3 form-inline">
        <input type="text" placeholder="每个IP发送短信次数"  name="ip_send_sms_num" id="ip_send_sms_num"  class="form-control" value="{{$configure['ip_send_sms_num'] or 200}}">&nbsp;&nbsp;
    </div>
</div>

<div class="form-group">
    <label class="col-sm-3 control-label"></label>
    <div class="col-sm-9">
        <input type="hidden" name="function_id" id="function_id" value="{{ $function_id or ''}}">
        <input type="button"  value="保存" onclick="func.edit();" class="btn btn-success" >
    </div>
</div>

@endsection
@section('js')
    <script>

        layui.use(['form'], function(){
            var form = layui.form();
        });

        var func = {

            //保存
            edit:function(){

                var message_log = '' ;
                var configure = E.getFormValues('edit-form') ;

                //参数判断
                if( E.isEmpty( configure.function_id ) || !E.isInt( configure.function_id ) ) {
                    message_log += '参数错误<br/>' ;
                }
                if ( E.isEmpty(configure.send_show_img_yzm) ) {
                    message_log +='请输入图片验证码次数<br/>';
                }

                if ( !E.isInt(configure.send_show_img_yzm) ) {
                    message_log +='图片验证码次数须为整数<br/>';
                }

                if ( E.isEmpty(configure.sms_send_time) ) {
                    message_log +='请输入短信发送间隔时间<br/>';
                }

                if ( !E.isInt(configure.sms_send_time) ) {
                    message_log +='短信发送间隔时间须为整数<br/>';
                }

                if ( E.isEmpty(configure.mobile_send_sms_num) ) {
                    message_log +='请输入每个手机号发送短信次数<br/>';
                }

                if ( !E.isInt(configure.mobile_send_sms_num) ) {
                    message_log +='每个手机号发送短信次数须为整数<br/>';
                }

                if ( E.isEmpty(configure.ip_send_sms_num) ) {
                    message_log +='请输入每个IP发送短信次数<br/>';
                }

                if ( !E.isInt(configure.ip_send_sms_num) ) {
                    message_log +='每个IP发送短信次数须为整数<br/>';
                }

                if( message_log ) {
                    layer.alert( message_log , { icon:2 });
                    return false ;
                }

                layer.confirm("您确认保存该设置吗？",{icon:3,offset:'50px'}, function ( index ){
                    layer.close( index );
                    E.ajax( {
                        type:'get',
                        url: '/lar/develop/function/store/'+function_id,
                        data: configure,
                        dataType:'json',
                        // 返回值判断
                        success: function ( obj ){

                            if ( obj.code == 200 ) {
                                layer.alert( obj.message , { icon: 1,time : 1500 } ) ;
                            } else {
                                layer.alert( obj.message , { icon: 2 } ) ;
                            }
                        }
                    } ) ;
                });
            }
        };
    </script>
@endsection